package com.yc.blog.web;

import biz.BizException;
import com.yc.blog.vo.Result;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import reactor.core.publisher.Mono;

@RestControllerAdvice
public class ExHandler {

    @ExceptionHandler(BizException.class)
    Mono<Result> bizException(BizException e){
        return Mono.just(Result.err(e.getMessage()));
    }

    @ExceptionHandler(Exception.class)
    Mono<Result> exception(Exception e){
        e.printStackTrace();
        return Mono.just(Result.err("系统异常，请联系管理员！"));
    }

}
